<%@ Page Language="C#" MasterPageFile="~/MasterDefault.master" AutoEventWireup="true"
    Inherits="TeamTime.PersonsForm" Title="TeamTime Management System - People Maintenance"
    StylesheetTheme="Default" CodeBehind="PersonsForm.aspx.cs" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="PersonFormControl.ascx" TagName="PersonFormControl" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true">
        <Services>
            <asp:ServiceReference Path="AutoComplete.asmx" />
        </Services>
    </asp:ScriptManager>
    <clib:UpdatePanelExtender runat="server" ID="UpdatePanelExtender1" UpdateMode="Conditional">
        <ContentTemplate>
            <h3>
                People &nbsp; &nbsp;<asp:Button runat="server" ID="btnAddNew" Text="Add New" OnClick="btnAddNew_Click"
                    CausesValidation="False" />
            </h3>
            <asp:Button runat="server" ID="btnAddDummy" Text="Add New" Visible="true" Style="display: none;" />
            <clib:ModalPopupPanel runat="server" ID="popUp1" TargetControlID="btnAddDummy" Width="670"
                Title="Person">
                <uc1:PersonFormControl ID="PersonFormControl1" runat="server" OnLoadDupClicked="PersonFormControl1_LoadDupClicked"
                    OnSaveClicked="PersonFormControl1_SaveClicked" OnListsBuilt="PersonFormControl1_ListsBuilt"
                    OnMembershipChanged="PersonFormControl1_MembershipChanged" />
            </clib:ModalPopupPanel>
            <asp:Panel ID="pnlSearch" runat="server" DefaultButton="btnSearch">
                <table id="tblHead" cellspacing="0" cellpadding="1" border="0" runat="server" width="">
                    <tr>
                        <td>
                            Search for&nbsp;
                        </td>
                        <td>
                            <asp:TextBox ID="txtSearchFor" runat="server" MaxLength="100" Width="200px"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            in Company
                        </td>
                        <td>
                            <asp:TextBox ID="txtCompanyNameSearch" runat="server" Width="200px"></asp:TextBox>
                            <ajaxToolkit:AutoCompleteExtender runat="server" ID="extCompanyNameSearch" TargetControlID="txtCompanyNameSearch"
                                ServicePath="AutoComplete.asmx" ServiceMethod="getCompanies" MinimumPrefixLength="1"
                                EnableCaching="true" OnClientPopulating='show1' OnClientPopulated='hide1' SkinID="AutoCompleteExtender" />
                            <img id="imgProg1" src="App_Themes/Default/Images/ajaxloader.gif" alt="prog" style="visibility: hidden;" />

                            <script type="text/javascript">
                                function show1() { getEl('imgProg1').style.visibility = 'visible'; }
                                function hide1() { getEl('imgProg1').style.visibility = 'hidden'; }
                            </script>

                        </td>
                        <td>
                            Office
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlOfficeID" runat="server">
                            </asp:DropDownList>
                        </td>
                        <td>
                            <asp:Button ID="btnSearch" runat="server" Text="Search >>" CausesValidation="False"
                                OnClick="btnSearch_Click"></asp:Button>
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <br />
            <asp:Label ID="lblMsg" runat="server" EnableViewState="false" CssClass="infoLabel"
                Style="display: none;"></asp:Label>
            <asp:TextBox ID="txtNoDel" runat="server" Style="display: none;" />
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" SkinID="GridView"
                AllowPaging="True" PageSize="20" AllowSorting="True" DataKeyNames="ID" OnPageIndexChanging="GridView1_PageIndexChanging"
                OnRowCommand="GridView1_RowCommand" OnRowDeleting="GridView1_RowDeleting" 
                onsorting="GridView1_Sorting">
                <Columns>
                    <asp:TemplateField HeaderText="" SortExpression="ID">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkID" runat="server" CausesValidation="false" CommandName="Select"
                                Text="Edit" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName">
                    </asp:BoundField>
                    <asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname">
                    </asp:BoundField>
                    <asp:BoundField DataField="IDNumber" HeaderText="ID Number" SortExpression="IDNumber">
                    </asp:BoundField>
                    <asp:BoundField DataField="PostalAddress" HeaderText="Postal Address" SortExpression="PostalAddress"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="ResidentialAddress" HeaderText="Residential Address" SortExpression="ResidentialAddress"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="CompanyName" HeaderText="Company" SortExpression="CompanyName">
                    </asp:BoundField>
                    <asp:BoundField DataField="Office" HeaderText="Office" SortExpression="Office" Visible="false">
                    </asp:BoundField>
                    <asp:BoundField DataField="Department" HeaderText="Department" SortExpression="Department"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="PositionHeld" HeaderText="Position" SortExpression="PositionHeld">
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="Email" SortExpression="EmailAddress">
                        <ItemTemplate>
                            <asp:HyperLink ID="hypEmail" runat="server" NavigateUrl='<%# "mailto:" + DataBinder.Eval(Container, "DataItem.Email") %>'
                                Text='<%# DataBinder.Eval(Container, "DataItem.Email") %>'><%# DataBinder.Eval(Container, "DataItem.Email") %></asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="TelWork" HeaderText="Work Telephone" SortExpression="TelWork">
                    </asp:BoundField>
                    <asp:BoundField DataField="TelCell" HeaderText="Cellphone" SortExpression="TelCell">
                    </asp:BoundField>
                    <asp:BoundField DataField="Fax" HeaderText="Fax" SortExpression="Fax" Visible="false">
                    </asp:BoundField>
                    <asp:BoundField DataField="EthnicOrigin" HeaderText="Race" SortExpression="EthnicOrigin"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="IsHistoricallyDisadvantaged" HeaderText="HDI" SortExpression="IsHistoricallyDisadvantaged"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="IsDisabled" HeaderText="Disabled" SortExpression="IsDisabled"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="DateOfBirth" HeaderText="Date Of Birth" SortExpression="DateOfBirth"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="DietaryRequirements" HeaderText="Dietary Requirements"
                        SortExpression="DietaryRequirements" Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="TShirtSize" HeaderText="T-Shirt Size" SortExpression="TShirtSize"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" Visible="false">
                    </asp:BoundField>
                    <asp:BoundField DataField="RecordDate" HeaderText="Record Date" SortExpression="RecordDate"
                        Visible="false"></asp:BoundField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Delete"
                                Text="Delete" OnClientClick='JavaScript:return confirm("Are you sure?");' CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    No records found</EmptyDataTemplate>
                <PagerTemplate>
                    <table width="100%">
                        <tr>
                            <td style="text-align: left; font-size: 11px; width: 100px;">
                                Page
                                <asp:Label ID="lblPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                of
                                <asp:Label ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount  %>' />
                            </td>
                            <td style="text-align: center; font-size: 11px;">
                                <asp:Panel ID="pnlPager" runat="server" DefaultButton="lnkGo">
                                    <asp:LinkButton ID="lnkFirst" runat="server" CausesValidation="False" CommandArgument="First"
                                        CommandName="Page" Text="Page 1" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
                                        CommandName="Page" Text="<< Prev" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkNext" runat="server" CausesValidation="False" CommandArgument="Next"
                                        CommandName="Page" Text="Next >>" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkLast" runat="server" CausesValidation="False" CommandArgument="Last"
                                        CommandName="Page" Text='<%# "Page "+ ((GridView)Container.Parent.Parent).PageCount  %>' />&nbsp;&nbsp;&nbsp;
                                    <asp:TextBox ID="txtNewPageIndex" runat="server" Width="20px" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                    <asp:LinkButton ID="lnkGo" runat="server" CausesValidation="False" CommandArgument="-1"
                                        CommandName="Page" Text="Go" /><!-- here set the CommandArgument of the Go Button to '-1' as the flag -->
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                </PagerTemplate>
            </asp:GridView>

            <script type="text/javascript" id="sc1">
                function pageLoad() {
                    var l = document.getElementById('<%# lblMsg.ClientID %>');
                    if (l != null) {
                        if (l.innerHTML > '') {
                            alert(l.innerHTML);
                        }
                    }

                }
            </script>

        </ContentTemplate>
    </clib:UpdatePanelExtender>
</asp:Content>
